<%@ page language="java" import="pos.domain.*,java.util.*" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Perfil</title>

<style type="text/css">
body {
	background-color:#4F4F4F
	
	
	
}
div {
	background-color:#CD5A24;
	margin-right:300px;
	margin-left: 200px;
	color: #333;
}
</style>
</head>
<body>
<p><img src= "http://www.thepropertyexchange.com.au/images/prop-header.png" /> 


<%UserManager um=new UserManager();
User u=um.getUser((String)session.getAttribute("session.user"));
%>

<form method="post" name="IntercambiosRecibidos" action="IntercambiosRecibidos.jsp">
	<input type="submit" name="IntercambiosRecibidos" value="IntercambiosRecibidos">
</form>
<br>
<table>
	<tr>
    <td>Nombre</td>
    <td> <%=u.getName() %></td>
  	</tr>
  	<tr>
    <td>Apellidos</td>
    <td><%=u.getSurname()%></td>
  	</tr>
  	<tr>
    <td>email</td>
    <td><%=u.getEmail()%><br></br></td>
  	</tr>
</table>

<table>
	<tr><br><b> VALORACIONES PENDIENTES</b></br></tr>
	<tr>
		<td>Usuario a valorar</td>	<td>Casa a valorar</td>	<td>Valorar intercambio</td>
	</tr>



<%
       ExchangeManager em= new ExchangeManager();
        HttpSession session1 = request.getSession(false);
		String email = (String) session.getAttribute("session.user");
       List<Exchange> exchanges = em.getExchangeForRating(email);
        for (Iterator<Exchange> iter = exchanges.iterator(); iter.hasNext();) {
            Exchange e = (Exchange) iter.next();
            
            String userRat=e.getEmailSent();//quiero valorar al otro usuario
            String property=e.getPropertySentID();//quiero valorar la casa del otro
            if(e.getEmailSent().equals(email)){
            	//cambios para controlar cuando soy yo 	quien envia las peticiones
            	userRat=e.getEmailReceived();
            	property=e.getPropertyReceivedID();
            
            }
%>
		<tr>	
				
				<td> <%=userRat%></td>
				<td> <%=property%></td>
				
				<td> <a href="FrontController?res=valorar.jsp?eid=<%=e.getExchangeID()%>"><img src='img/Intercambio.gif'> </a></td>
			</tr>
<%
        }
%>

</table>
</body>
</html>